package cn.hl.hm.logic.serviceImpl;

import cn.hl.hm.constants.DriverStatus;
import cn.hl.hm.constants.DriverVehicleStatus;
import cn.hl.hm.constants.ModelConfig;
import cn.hl.hm.entity.*;
import cn.hl.hm.logic.service.IDriverService;
import cn.hl.hm.logic.st.StDriverLogic;
import cn.hl.hm.service.*;
import cn.hl.hm.util.*;
import cn.hl.hm.util.paging.PageInfo;
import cn.hl.hm.vo.DriverDetailVo;
import cn.hl.hm.vo.DriverInfoVo;
import cn.hl.hm.vo.VehicleVo;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import smsClient.TestSDKClient;

import java.io.File;
import java.math.BigDecimal;
import java.sql.SQLDataException;
import java.util.*;

/**
 * @description: 司机和车辆逻辑处理
 * @Author: xianghan
 * @Date: 2017/10/27 14:51
 **/
@Service
class IDriverServiceImpl implements IDriverService {
    private static final Logger logger = LoggerFactory.getLogger(IDriverServiceImpl.class);
    @Autowired
    DriverService driverService;
    @Autowired
    private BeanPicUtil beanPicUtil;
    @Autowired
    private DriverVehicleService driverVehicleService;
    @Autowired
    private VehicleService vehicleService;
    @Autowired
    private VehicleLengthService vehicleLengthService;
    @Autowired
    private VehicleTypeService vehicleTypeService;
    @Autowired
    @Qualifier("pushToAppServiceImpl")
    private PushToAppIService pushToAppIService;
    @Autowired
    private DriverOwnInfoService driverOwnInfoService;
    
    @Autowired
	private OSSUtil ossutil;

    @Autowired
    private StDriverLogic stDriverLogic;

    @Override
    public DriverInfoVo getDriverInfo(Integer driverId) {
        Driver param = new Driver();
        param.setId(driverId);
        List<Driver> selectDrivercheck = driverService.selectDriver(param);
        if (selectDrivercheck != null && selectDrivercheck.size() > 0) {
            Driver d = selectDrivercheck.get(0);
            if (d.getVehicleTypeId() != null) {
                param.setDriverStatus(d.getDriverStatus());
            }
            List<Driver> selectDriver = driverService.selectDriverInfo(param);
            if (selectDriver != null && selectDriver.size() > 0) {
                //可用余额
                selectDriver.get(0).setUsableCash(selectDriver.get(0).calculateRemainCash());
                Driver modifyUrl = null;
                try {
                    modifyUrl = beanPicUtil.modifyUrl(selectDriver.get(0));
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return new DriverInfoVo(modifyUrl);
            }
        }
        return null;
    }

    @Override
    public List<DriverDetailVo> getDriverPageList(PageInfo pageInfo) {
        try {
            List<Driver> driverList = driverService.selectDriverInfoListPage(pageInfo);
            return getDriverPageList(driverList);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public List<DriverDetailVo> getDriverPageList(List<Driver> driverList) {
        try {
            if (driverList!=null && driverList.size()>0) {
                List<Integer> driverIds = List2Map.getInstance().getFieldList("getId", driverList);
                //排除3 删除状态的车辆
                List<Integer> statusIds = Arrays.asList(0, 1, 2);
                List<DriverVehicle> driverVehicleList = driverVehicleService.selectListByDriversAndStatus
                        (driverIds, statusIds);
                Map<Integer, List<DriverVehicle>> maps = List2Map.getInstance().tobeLinkedHashMaps
                        ("getDriverId",
                                driverVehicleList);
                List<DriverDetailVo> driverInfoVoList = new ArrayList<>();
                DriverDetailVo driverVo = null;
                OrderVO orders=null;
                driverService.fillChargeSetting(driverList);
                int vehicleCheckingCount=0;
                for (Driver driver : driverList) {
                    beanPicUtil.modifyUrl(driver);
                    orders = driverService.selectOrderOtherInfo(driver.getId());
                    if(orders!=null && orders.getTotalIncome()!=null && orders.getTotalIncome().length()>0){
                        driver.setTotalIncome(new BigDecimal(orders.getTotalIncome()));
                    }
                    driverVo = new DriverDetailVo(driver);
                    driverVo.setRemainCash(driver.calculateRemainCash());
                    List<DriverVehicle> driverVehicles = maps.get(driverVo.getId());
                    if (driverVehicles != null) {
                        driverVo.setVehiclleCount(maps.get(driverVo.getId()).size());
                        for (DriverVehicle driverVehicle : driverVehicles) {
                            if (driverVehicle.getStatus()==(DriverVehicleStatus.WAIT_AUDIT.getStatus().byteValue())) {
                                vehicleCheckingCount+=1;
                            }
                        }
                        driverVo.setVehicleCheckingCount(vehicleCheckingCount);
                        vehicleCheckingCount=0;
                    }
                    driverInfoVoList.add(driverVo);
                }
                return driverInfoVoList;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public DriverDetailVo getDriverDetail(Integer driverId,String driverPhone) {
        try {
            Driver driver=null;
            //2018-01-02 兼容新增充值时按手机号码搜索司机
            if (driverId != null) {
                driver = driverService.selectByPrimaryKey(driverId);
            } else if (StringUtils.isNotBlank(driverPhone)) {
                driver=new Driver();
                driver.setDriverPhone(driverPhone);
                List<Driver> drivers = driverService.selectDriver(driver);
                if (drivers!=null && drivers.size()>0) {
                    driver=drivers.get(0);
                }else{
                    return null;
                }
            }
            if (driver != null) {
                driver = beanPicUtil.modifyUrl(driver);
                driver.setHeadPic(ImageUtils.adaptive(driver.getHeadPic()));
                driver.setPlateNumberPic(ImageUtils.adaptive(driver.getPlateNumberPic()));
                driver.setQualificationCertificatePic(ImageUtils.adaptive(driver.getQualificationCertificatePic()));
                driver.setDriverLicensePic(ImageUtils.adaptive(driver.getDriverLicensePic()));
                driver.setIdCardFrontPic(ImageUtils.adaptive(driver.getIdCardFrontPic()));
                driver.setIdCardBackPic(ImageUtils.adaptive(driver.getIdCardBackPic()));
                DriverDetailVo driverDetailVo = new DriverDetailVo(driver);
                driverDetailVo.setVehicleList(getVehicleList(driver.getId()));
                driverDetailVo.setRemainCash(driver.calculateRemainCash());
                OrderVO o = driverService.selectOrderOtherInfo(driver.getId());
                if (o != null) {
                    if (o.getTotalIncome() != null && o.getTotalIncome().length()>0) {
                        driverDetailVo.setTotalIncome(new BigDecimal(o.getTotalIncome()));
                    }
                    if (o.getTotalOrderCount() != null && o.getTotalOrderCount().length()>0) {
                        driverDetailVo.setSuccessOrderCount(Integer.valueOf(o.getTotalOrderCount()));
                    }
                }
                return driverDetailVo;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }


    @Override
    public Boolean addVehicle(Integer driverId, String plateNumber, Integer vehicleTpyeId,
                              Integer vehicleLengthId, String transportLicense,
                              String drivingLicensePic, String drivingLicenseGuaPic,Integer status) throws
            SQLDataException {
        try {
            //判断是否已经存在该车牌号的车辆
            Vehicle vehicle = vehicleService.selectByPlateNumber(plateNumber);
            //没有-》创建-》关联绑定
            if (vehicle == null) {
                vehicle = new Vehicle();
                vehicle.setPlateNumber(plateNumber);
                vehicle.setCreateBy(driverId);
                vehicle.setCreateTime(new Date());
                vehicleService.insertSelective(vehicle);
                List driverVehicleList = driverVehicleService.selectByDIVI(driverId,
                        vehicle.getId());
                if (driverVehicleList.isEmpty()) {
                    insertDriverCehicle(driverId, plateNumber, vehicleTpyeId, vehicleLengthId, transportLicense, drivingLicensePic, drivingLicenseGuaPic, status, vehicle.getId());
                }
                return true;
            }else{
                List driverVehicleList = driverVehicleService.selectByDIVI(driverId,
                        vehicle.getId());
                if(driverVehicleList.isEmpty()){
                    insertDriverCehicle(driverId, plateNumber, vehicleTpyeId, vehicleLengthId,
                            transportLicense, drivingLicensePic, drivingLicenseGuaPic, status, vehicle.getId());
                    return true;
                }else {
                    //车辆已存在，不能再次添加
                    throw new SQLDataException();
                }
            }
        } catch (Exception e) {
            if (e instanceof SQLDataException) {
                throw (SQLDataException) e;
            } else {
                e.printStackTrace();
            }
        }
        return false;
    }

    public void insertDriverCehicle(Integer driverId, String plateNumber, Integer vehicleTpyeId, Integer
            vehicleLengthId, String transportLicense, String drivingLicensePic, String
            drivingLicenseGuaPic, Integer status, Integer vehicleId) throws Exception {
        DriverVehicle driverVehicle = new DriverVehicle();
        driverVehicle.setVehicleId(vehicleId);
        //TODO 待修改
        driverVehicle.setDriverId(driverId);
        driverVehicle.setCreateTime(new Date());
        driverVehicle.setDrivingGuaPic(drivingLicenseGuaPic);
        driverVehicle.setDrivingLicensePic(drivingLicensePic);
        driverVehicle.setPlateNumber(plateNumber);
        driverVehicle.setTransportLicense(transportLicense);
        driverVehicle.setUpdateTime(driverVehicle.getCreateTime());
        driverVehicle.setVehicleLengthId(vehicleLengthId);
        driverVehicle.setVehicleTypeId(vehicleTpyeId);
        driverVehicle.setStatus(status.byteValue());
        beanPicUtil.cutUrl(driverVehicle);
        driverVehicleService.insertSelective(driverVehicle);
//        stDriverLogic.ayncVehicel(driverVehicle.getId());
    }

    @Override
    public Boolean updateVehicle(Integer driverId, String plateNumber, Integer vehicleTpyeId, Integer
            vehicleLengthId, String transportLicense, String drivingLicensePic, String drivingLicenseGuaPic,
                                 Integer status, String assessorUsername, String driverUnpassReason) {
        try {
            //判断是否已经存在该车牌号的车辆
            Vehicle vehicle = vehicleService.selectByPlateNumber(plateNumber);
            if (vehicle != null) {
                DriverVehicle driverVehicle = new DriverVehicle();
                driverVehicle.setVehicleId(vehicle.getId());
                driverVehicle.setDriverId(driverId);
                List<DriverVehicle> driverVehicleList = driverVehicleService.selectByDIVI(driverVehicle
                        .getDriverId(), driverVehicle.getVehicleId());
                if (driverVehicleList != null && driverVehicleList.size() > 0) {
                    driverVehicle.setId(driverVehicleList.get(0).getId());
                    driverVehicle.setVehicleTypeId(vehicleTpyeId);
                    driverVehicle.setVehicleLengthId(vehicleLengthId);
                    driverVehicle.setTransportLicense(transportLicense);
                    driverVehicle.setDrivingLicensePic(drivingLicensePic);
                    driverVehicle.setDrivingGuaPic(drivingLicenseGuaPic);
                    if (status != null) {
                        driverVehicle.setStatus(status.byteValue());
                    }
                    driverVehicle.setDriverUnpassReason(driverUnpassReason);
                    driverVehicle.setAssessorUsername(assessorUsername);
                    beanPicUtil.cutUrl(driverVehicle);
                    driverVehicleService.updateByPrimaryKeySelective(driverVehicle);
//                    stDriverLogic.ayncVehicel(driverVehicle.getId());
                    return true;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    @Override
    public Boolean deleteVehicle(Integer driverId, Integer vehicleId) {
        try {
            //判断是否已经存在该车牌号的车辆
            Vehicle vehicle = vehicleService.selectByPrimaryKey(vehicleId);
            if (vehicle != null) {
                DriverVehicle driverVehicle = new DriverVehicle();
                driverVehicle.setVehicleId(vehicle.getId());
                driverVehicle.setDriverId(driverId);
                List<DriverVehicle> driverVehicleList = driverVehicleService.selectByDIVI(driverVehicle
                        .getDriverId(), driverVehicle.getVehicleId());
                if (!driverVehicleList.isEmpty()) {
                    driverVehicleService.deleteByPrimaryKey(driverVehicleList.get(0).getId());
//                    stDriverLogic.ayncVehicel(driverVehicleList.get(0).getId());
                }
            }
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    @Override
    public Driver addDriver(Driver driver) {
        try {
            String pass = NumberUtils.getRandomNumber(6);
            driver.setPassword(MD5Util.MD5Encode(MD5Util.MD5Encode(pass, "UTF-8"), "UTF-8"));
            driver.setDriverStatus(DriverStatus.PASS.getStatus());
            driver.setDriverAccount(driver.getDriverPhone());
            driver.setCreateTime(new Date());
            beanPicUtil.cutUrl(driver);
            // 二维码
            String preUrl = ModelConfig.ENV_TEST;
            String rebackUrl = ModelConfig.QR_PIC_DRIVER_LONG_TEST;

            if (ModelConfig.status.equals("1")) {
                preUrl = ModelConfig.ENV_ONLINE;
                rebackUrl = ModelConfig.QR_PIC_DRIVER_LONG_ONLINE;

            }
            String content = preUrl + "driverController/selectInfoByget?driverAccount=" + driver.getDriverAccount();
            String destPath = ModelConfig.QR_PIC_DRIVER_SHORT;

            String finalPicUrl = QRCodeUtil.encodeDriverOrPay(content, destPath, false);
//            StringBuffer sb = new StringBuffer();
//            // 回显路径
//            String str = sb.append(rebackUrl).append(finalPicUrl).toString();
            // TODO 入库 并返回客户端
            File file =new File(destPath+finalPicUrl);
            if(file.exists()) {
            	ossutil.putObject("hm/qrInfo/"+finalPicUrl, file);
            // TODO 入库 并返回客户端
            	driver.setQrInfo("hm/qrInfo/"+finalPicUrl);
            FileUtil.delFile(destPath+finalPicUrl);
            }
            driverService.insertSelective(driver);
            transferVehicle(driver);
            if(driver.getId()!=null){
                // 发短信
                SendSmsRequest smsRequest = new SendSmsRequest();
                smsRequest.setTemplateParam("{\"driverAccount\":\""+driver.getDriverAccount()+"\",\"pass\":\""+pass+"\"}");
                TestSDKClient.sendSmsByAli("SMS_110435049",smsRequest,driver.getDriverAccount(),"华凌叮当到");
            }
            return driver;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public int deleteDriver(Integer driverId) {
        return driverService.deleteByPrimaryKey(driverId);
    }

    @Override
    public List<Driver> selectListByIds(List<Integer> ids) {
        return driverService.selectListByIds(ids);
    }

    @Override
    public List<Integer> selectDriverListPage(PageInfo pageInfo) {
        return driverVehicleService.selectDriverListPage(pageInfo);
    }

    @Override
    public List<Integer> selectExistCheckPendingListPage(PageInfo pageInfo) {
        return driverVehicleService.selectExistCheckPendingListPage(pageInfo);
    }

    @Override
    public int updateDriver(Driver driver) {
        try {
//            Driver driver = new Driver();
            Driver param = new Driver();
            if (driver.getId() != null) {
                param.setId(driver.getId());
            }
            param.setDriverAccount(driver.getDriverAccount());
            driver = beanPicUtil.cutUrl(driver);
            Driver result =null;
            List<Driver> selectDriver = driverService.selectDriver(param);
            if (selectDriver != null && selectDriver.size() > 0) {
                result = selectDriver.get(0);
                driver.setId(result.getId());
                driver.setUpdateTime(new Date());
                if (result.getQrInfo() != null && !"".equals(result.getQrInfo())) {
                    driver.setQrInfo(result.getQrInfo());
                }
//                if (StringUtils.isNotBlank(appId)) {
//                    driver.setPlatformId(appId);
//                }
                fillDriverQrInfo(driver);

                beanPicUtil.cutUrl(driver);
                //司机修改个人信息默认变为审核中
                if (StringUtils.isBlank(driver.getDriverStatus())) {
                    driver.setDriverStatus(DriverStatus.WAIT_AUDIT.getStatus());
                }else if(driver.getDriverStatus().equals(DriverStatus.FAIL.getStatus())){//如果司机状态修改为未通过，车辆状态也变成未通过
                    DriverVehicle driverVehicle=new DriverVehicle();
                    driverVehicle.setDriverId(driver.getId());
                    driverVehicle.setStatus(DriverVehicleStatus.FAIL.getStatus().byteValue());
                    driverVehicleService.updateByPrimaryKeySelective(driverVehicle);
                }
                int rows = driverService.updateByPrimaryKeySelective(driver);
//                stDriverLogic.ayncDriver(driver.getId());
                transferVehicle(driver);
                if (rows >0 && !result.getDriverStatus().equals(driver.getDriverStatus())) {
                    driverCheckPush(driver.getDriverStatus(), result);
                }
                return rows;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return 0;
    }

    /**
     * 一人一车版本车辆数据兼容到一人多车
     * 司机回到旧版修改车辆信息，同步到到新表数据中
     * @param driver
     * @throws SQLDataException
     */
    private void transferVehicle(Driver driver) throws SQLDataException {
        //一人一车逻辑兼容
        if(driver.getPlateNumber()!=null && driver.getPlateNumber().length()>0){
            List<DriverVehicle> driverVehicles = driverVehicleService.selectByIdAndNumberAndState
                    (driver.getId(), driver.getPlateNumber(), null);
            int index=Integer.valueOf(driver.getDriverStatus())-2;
            if(index<0){
                index=0;
            }
            if (driverVehicles!=null&&driverVehicles.size()>0) {
                updateVehicle(driver.getId(), driver.getPlateNumber(),
                        driver.getVehicleTypeId() == null ? null : Integer.valueOf(driver
                                .getVehicleTypeId()),
                        driver.getVlId() == null ? null : Integer.valueOf(driver.getVlId()),
                        driver.getRoadTransportCertificateNumber(), driver.getDrivingLicensePic(),
                        driver.getDrivingGuaPic(),
                        DriverVehicleStatus.values()[index].getStatus(), null, null);
            }else{
                addVehicle(driver.getId(), driver.getPlateNumber(),
                        driver.getVehicleTypeId() == null ? null : Integer.valueOf(driver
                                .getVehicleTypeId()),
                        driver.getVlId() == null ? null : Integer.valueOf(driver.getVlId()),
                        driver.getRoadTransportCertificateNumber(), driver.getDrivingLicensePic(),
                        driver.getDrivingGuaPic(), DriverVehicleStatus.values()[index].getStatus());
            }
        }
    }

    private void fillDriverQrInfo(Driver driver) throws Exception {
        if (driver.getQrInfo() == null) {
            // 二维码
            String preUrl = ModelConfig.ENV_TEST;
            String rebackUrl = ModelConfig.QR_PIC_DRIVER_LONG_TEST;

            if (ModelConfig.status.equals("1")) {
                preUrl = ModelConfig.ENV_ONLINE;
                rebackUrl = ModelConfig.QR_PIC_DRIVER_LONG_ONLINE;

            }
            String content = preUrl + "driverController/selectInfoByget?driverAccount=" + driver.getDriverPhone();
            String destPath = ModelConfig.QR_PIC_DRIVER_SHORT;

            String finalPicUrl = QRCodeUtil.encodeDriverOrPay(content, destPath, false);
//            StringBuffer sb = new StringBuffer();
//            // 回显路径
//            String str = sb.append(rebackUrl).append(finalPicUrl).toString();
            // TODO 入库 并返回客户端
            File file =new File(destPath+finalPicUrl);
            if(file.exists()) {
            	ossutil.putObject("hm/qrInfo/"+finalPicUrl, file);
            // TODO 入库 并返回客户端
            driver.setQrInfo("hm/qrInfo/"+finalPicUrl);
            FileUtil.delFile(destPath+finalPicUrl);
            }
        }
    }

    public void driverCheckPush(String driverStatus, Driver driver) {
            if (driver!=null && StringUtils.isNotBlank(driver.getDeviceToken())) {
                if (driverStatus.equals(DriverStatus.PASS.getStatus())) {
                    Push push = new Push();
                    push.setBizzType(Push.BizzTypeEnum.USER.getName());
                    push.setPtype(Push.PushTypeEnum.USERPUSH3.getId());
                    push.setPushoid("");
                    push.setDisplayType("notification");// message:// 消息，通知：notification
                    push.setOperationType(1);// 用户类型：1司机，2发货端
                    push.setPushClient("driverPushClient");// 使用的推送Client
                    push.setPushType("listcast");// unicast：单播 // listcast：列表
                    push.setTokenStr(new String[]{driver.getDeviceToken()}); // 要发送手机的token
                    push.setContext("恭喜您，资料已审核成功，马上开始接单吧");// 要发送的内容
                    push.setTitle("资料审核通过"); // 发送的标题
                    driverOwnInfoService.insertSelective(push.getContext(),driver.getId());
                    // ios & android推送公共调用方法
                    pushToAppIService.pushCommon(push);
                    return ;
                }
                if (driverStatus.equals(DriverStatus.FAIL.getStatus())) {
                    Push push = new Push();
                    push.setBizzType(Push.BizzTypeEnum.USER.getName());
                    push.setPtype(Push.PushTypeEnum.USERPUSH5.getId());
                    push.setPushoid("");
                    push.setDisplayType("notification");// message:// 消息，通知：notification
                    push.setOperationType(1);// 用户类型：1司机，2发货端
                    push.setPushClient("driverPushClient");// 使用的推送Client
                    push.setPushType("listcast");// unicast：单播 // listcast：列表
                    push.setTokenStr(new String[]{driver.getDeviceToken()}); // 要发送手机的token
                    push.setContext("温馨提示，您的司机资料审核未通过，请至个人重新查看并重新提交。");// 要发送的内容
                    push.setTitle("资料审核失败"); // 发送的标题
                    driverOwnInfoService.insertSelective(push.getContext(),driver.getId());
                    // ios & android推送公共调用方法
                    pushToAppIService.pushCommon(push);
                }
            }
    }

    public List<VehicleVo> getVehicleList(List<DriverVehicle> driverVehicleList) {
        List<VehicleVo> results = null;
        try {
            if (List2Map.getInstance().isNotEmpty(driverVehicleList)) {
                List<Integer> vtIds = new ArrayList<Integer>();
                List<Integer> vlIds = new ArrayList<Integer>();
                for (DriverVehicle driverVehicle : driverVehicleList) {
                    vtIds.add(driverVehicle.getVehicleTypeId());
                    vlIds.add(driverVehicle.getVehicleLengthId());
                }
                Map<Integer, VehicleType> vehicleTypeMap = List2Map.getInstance().tobeMap("getId",
                        vehicleTypeService.selectByIds(new ArrayList<Integer>(new HashSet<Integer>(vtIds))));
                Map<Integer, VehicleLength> vehicleLengthMap = List2Map.getInstance().tobeMap("getId",
                        vehicleLengthService.selectByIds(new ArrayList<Integer>(new HashSet<Integer>(vlIds))));
                results = new ArrayList<VehicleVo>();
                VehicleVo vehicleVo = null;
                for (DriverVehicle driverVehicle : driverVehicleList) {
                    vehicleVo = new VehicleVo(driverVehicle);
                    vehicleVo.setVehicleTpye(vehicleTypeMap.get(driverVehicle.getVehicleTypeId()).getName());
                    vehicleVo.setVehicleLength(vehicleLengthMap.get(driverVehicle.getVehicleLengthId())
                            .getVehicleLength());
                    beanPicUtil.modifyUrl(vehicleVo);
                    results.add(vehicleVo);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return results;
    }

    @Override
    public List<VehicleVo> getVehicleList(Integer driverId) {
        try {
            List<DriverVehicle> driverVehicleList = driverVehicleService.selectByDIVI(driverId, null);
            if (driverVehicleList!=null && driverVehicleList.size()>0) {
                for (DriverVehicle driverVehicle : driverVehicleList) {
                    driverVehicle.setVehiclePic(ImageUtils.adaptive(driverVehicle.getVehiclePic()));
                    driverVehicle.setDrivingLicensePic(ImageUtils.adaptive(driverVehicle.getDrivingLicensePic()));
                    driverVehicle.setDrivingGuaPic(ImageUtils.adaptive(driverVehicle.getDrivingGuaPic()));
                    driverVehicle.setDrivingLicense(ImageUtils.adaptive(driverVehicle.getDrivingLicensePic()));
                }
            }
            return getVehicleList(driverVehicleList);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        return null;
    }
}
